package com.woniuxy.micromedicalserver.departmentmanage.controller;


import com.woniuxy.micromedicalserver.bean.DepartmentBean;
import com.woniuxy.micromedicalserver.bean.ResultMsg;
import com.woniuxy.micromedicalserver.departmentmanage.service.IDepartmentService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/department")
@RestController
public class DepartmentController {

    @Resource
    private IDepartmentService departmentServiceImpl;

    @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultMsg getDepartmentByID(@PathVariable("id") Integer ID){
        DepartmentBean departmentBean = departmentServiceImpl.selectByID(ID);
        return new ResultMsg(true,departmentBean);
    }


    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultMsg getAllDepartment(DepartmentBean departmentBean){
        List<DepartmentBean> list = departmentServiceImpl.selectAllDepartment(departmentBean);
        return new ResultMsg(true,list);
    }






}
